/**
 * 工具类
 */
let Utils={
	//获取最大最小平均值
	getMinMaxAvg: function(arr, highIdx, lowIdx) {
		let max = 0;
		let min = 99999999;
		let avg = 0;
		let maxTime = "";
		let minTime = "";
		arr.forEach(res => {
			let r3 = parseFloat(res[highIdx]);
			let r4 = parseFloat(res[lowIdx]);
			max = r3 > max ? r3 : max;
			min = r4 < min ? r4 : min;
			maxTime = max == r3 ? res[0] : maxTime;
			minTime = min == r4 ? res[0] : minTime;
		})
		max = parseFloat(max);
		min = parseFloat(min);
		avg = (max + min) * 0.5;
		avg = parseFloat(avg.toFixed(2));
		return {
			maxTime: maxTime,
			minTime: minTime,
			max: max,
			min: min,
			avg: avg
		};
	},
	//获取日K
	vo:function(arr){
		return{
			open:parseFloat(arr[0]),
			close:parseFloat(arr[1]),
			max:parseFloat(arr[2]),
			min:parseFloat(arr[3])
		}
	},
	//获取波峰波谷
	findPeaks(data){
		
		    let peaks = [];
			let lows = [];
		    let n = data.length;
		    let m = n - 1;
		 
		    for (let i = 0; i < n; i++) {
		        if (i === 0 || i === m) continue; // 边界情况
		        if (data[i] > data[i - 1] && data[i] > data[i + 1]) {
		            peaks.push(i);
		        }
				if(data[i] <data[i-1] && data[i]< data[i+1]){
					lows.push(i)
				}
		    }
		   let obj = {};
		   obj.top=peaks;
		   obj.lows = lows;
		    return obj;
	},
}
	